import { C, N } from "../config/commonTypes"
import { Restfull } from "../config/resModel";
import { ErrotParams } from "../config/resCodeMsg";
// import { type } from "os";
type pa = {
    scriptName:string
     introduction: string
     manNum: string
     womenNum:number
}

const createScriptCheck = async (ctx:C, next:N) => {
    console.log("来到了参数校验");
    
    // const { scriptName, introduction,manNum,womenNum } = ctx.request.body.scriptBaseInfo
    if(!ctx.request.body.scriptBaseInfo) {
        ctx.body = Restfull.faild(ErrotParams)
        return
    } else {
        const keys = ["scriptName", "introduction","manNum","womenNum" ]
        const scriptBaseInfo:pa = ctx.request.body.scriptBaseInfo;
        for(let key of keys) {
            
            if(!scriptBaseInfo.hasOwnProperty(key)) {
                ctx.body = Restfull.faild({...ErrotParams,
                msg:`${key}未传递`})
                console.log("失败");
                
                return
            }
        }

    }
    await next()
}



export {
    createScriptCheck
}